package cn.zhutmj_bigmarket.domain.strategy.model.entity;

import cn.zhutmj_bigmarket.types.common.Constants;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * @description: 策略实体
 * @author: zhutmj
 * @createTime: 2025/7/511:30
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class StrategyEntity {

    /** 策略id **/
    private Long strategyId;
    /**  抽奖策略描述  **/
    private String strategyDesc;
    /**  策略规则    **/
    private String ruleModels;

    /**
     * 组装策略规则
     * @return
     */
    public String[] ruleModels() {
        if (StringUtils.isBlank(ruleModels)) return null;
        return ruleModels.split(Constants.SPLIT);
    }


    /**
     * 获取权重规则:只筛选出权重规则
     * @return
     */
    public String getStrategyWeight(){
        String[] ruleModels = ruleModels();
        for(String ruleModel : ruleModels){
            if("rule_weight".equals(ruleModel)){return ruleModel;}
        }
        return null;
    }



}
